package com.ias.agdis_r.volley.callback;

import com.android.volley.Response;
import com.android.volley.VolleyError;

import android.util.Log;

/**
 * 线程安全的单例异常处理类。volley请求服务器触发此回调时，多为网路异常，服务器异常，需要做特殊处理
 * 
 * @author Chipor
 *
 */
public class MyOnErrorListener implements Response.ErrorListener {

	private static final String TAG = MyOnErrorListener.class.getSimpleName();

	private static MyOnErrorListener instance;

	private MyOnErrorListener() {
	}

	/**
	 * 线程安全单例模式实现
	 * 
	 * @return
	 */
	public static MyOnErrorListener getInstance() {
		if (instance == null) {
			synchronized (MyOnErrorListener.class) {
				if (instance == null) {
					instance = new MyOnErrorListener();
				}
			}
		}
		return instance;
	}

	@Override
	public void onErrorResponse(VolleyError e) {
		Log.e(TAG, "volley err...");
		e.printStackTrace();
	}

}
